#ifndef COMMLAYER_H
#define COMMLAYER_H

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "mpi.h"

#include "Complex.h"

class CommLayer {

public:


	char hostname[MPI_MAX_PROCESSOR_NAME]; /** Hostname **/
	int namelength; /** Length of hostname **/
	int my_rank;            /* rank of process */
	int p;                  /* number of processes */
	int source;             /* rank of sender */
	int dest;               /* rank of receiver */
	int tag;            /* tag for messages */
	char message[100];      /* storage for message */
	MPI_Status status;      /* return status for receive */



	/** Constructors **/
	CommLayer(int argc, char * argv[]); 
	~CommLayer();

	/** accessors **/
	int rank() { return my_rank; }
	int procs() { return p; }

	/** Util Functions **/
	void sayHello();

	void sendComplex(Complex *c, int toRank);
	void sendComplex(Complex *c, int toRank,int iTag);

	void recvComplex(Complex *c, int fromRank);
	void recvComplex(Complex *c, int fromRank, int iTag);

	void barrier() { MPI_Barrier(MPI_COMM_WORLD); }
};

#endif

